import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm'
import { Staff } from 'src/modules/staff/entities/staff.entity'
import { WorkState } from 'src/modules/work-state/entities/work-state.entity'
import { ApplyStateEnum } from 'src/types/apply'
import { Admin } from 'src/modules/admin/entities/admin.entity'
import { App } from 'src/app.entity'
@Entity()
export class Apply extends App {
  @ManyToOne(() => Staff)
  @JoinColumn({ name: 'staff_id' })
  staff: Staff
  @ManyToOne(() => WorkState)
  @JoinColumn({ name: 'state_id' })
  workState: WorkState
  @ManyToOne(() => Admin)
  @JoinColumn({ name: 'admin_id' })
  admin?: Admin
  @Column({ type: 'varchar', length: 10 })
  reason: string
  @Column({ type: 'varchar', length: 80 })
  detail: string
  @Column({ type: 'varchar', length: 30, nullable: true })
  opinion?: string
  @Column({ type: 'varchar', length: 100 })
  content: string
  @Column({
    type: 'enum',
    enum: ApplyStateEnum,
    default: ApplyStateEnum['审核中']
  })
  state: string
  @Column({ type: 'boolean', default: false })
  reapply: boolean
  @Column({ type: 'varchar', length: 20, name: 'apply_date' })
  applyDate: string
  @Column({ type: 'varchar', length: 20, name: 'verify_date', nullable: true })
  verifyDate?: string
}
